<style>
    .comment .comment_lists {
        clear: both;
    }

    .comment .level_one,
    .comment .level_sec {
        display: flex;
    }

    .comment .comment_lists .level_sec {
        margin-top: 15px;
    }

    .comment .comment_lists .level_one .avatar img {
        width: 36px;
        height: 36px;
        border-radius: 36px;
    }

    .comment .comment_lists .level_sec .avatar img {
        width: 28px;
        height: 28px;
        border-radius: 28px;
    }

    .comment .comment_lists .user_content {
        margin-left: 15px;
        flex: 1;
    }

    .comment .comment_lists .user_content .nickname {
        color: #515756;
    }

    .comment .comment_lists .user_content .content {
        margin-top: 15px;
    }

    .comment .comment_lists .user_content .times_replay_op {
        margin-top: 5px;
    }

    .comment .comment_lists .user_content .times_replay_op a {
        margin-right: 15px;
        color: #8a919f
    }

    .comment .comment_lists .user_content .times_replay_op a.isop {
        color: #1e80ff;
    }

    .comment .cancel_reply {
        display: none;
    }

    .comment .more_comment_btn {
        background-color: #f2f3f5;
        margin-top: 12px;
        padding: 10px 0;
        width: 100%;
        text-align: center;
        display: block;
        border-radius: 5px;
    }

    .comment .more_reply_btn {
        margin-left: 43px;
        margin-top: 15px;
        display: block;
        color: #8a919f;
    }
</style>

<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding ">
        <div class=" rc-pannel layui-form">

            <div class="rc-pannel-body  rc-pagepadding comment">
                <div class="comment_lists" id="comment_lists">

                    <?php
                    foreach ($comments as $comment) {
                    ?>
                        <div class="level_one">
                            <div class="avatar">
                                <img src="<?php echo $comment->user['avatar'] == '' ? '/static/uc/images/avatar.png' : $comment->user['avatar'] ?>">
                            </div>
                            <div class="user_content">
                                <div class="nickname">
                                    <?php echo $comment->user['username'] ?>
                                </div>
                                <div class="content">
                                    <div>
                                        <?php echo $comment->content ?>
                                    </div>
                                    <div class="times_replay_op">
                                        <a> <?php echo $comment->createtime ?></a>
                                        <a class="delete_comment" data-id="<?php echo $comment->id ?>"> 删除</a>
                                    </div>

                                    <?php
                                    foreach ($comment->sec_comments as $seccomment) {
                                    ?>

                                        <div class="level_sec">
                                            <div class="avatar">
                                                <img src="<?php echo $seccomment->user['avatar'] == '' ? '/static/uc/images/avatar.png' : $seccomment->user['avatar'] ?>">

                                            </div>
                                            <div class="user_content">
                                                <div>
                                                    <span class="nickname">
                                                        <?php echo $seccomment->user['username'] ?>
                                                    </span>
                                                    <span class="">回复</span>
                                                    <span class="nickname"><?php echo $seccomment->toreplyuser['username'] ?>:</span>
                                                    <span class="content"><?php echo $seccomment->content ?></span>
                                                </div>
                                                <div class="times_replay_op">
                                                    <a><?php echo $seccomment->createtime ?></a>
                                                    <a class="delete_comment" data-id="<?php echo $seccomment->id ?>">删除</a>

                                                </div>
                                            </div>
                                        </div>
                                    <?php
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>

                    <?php
                    } ?>


                </div>


            </div>

            <div class="rc-pannel-footer " style="text-align:right">
                <div style="padding: 0 15px;">
                    <?php echo paginator($comments->total(), 10) ?>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    $(function() {
        layui.use(function() {
            $('.delete_comment').click(function() {
                var commentid = $(this).attr('data-id');
                layer.confirm('确定要删除么？', {
                    btn: ['确定', '关闭'] //按钮
                }, function() {
                    $.ajax({
                        url: '/app/cms/admin/Comment/delete?id=' + commentid, //请求路径
                        type: "POST", //请求方式
                        success: function(data) {
                            if (data.code == 0) {
                                window.location.reload();
                            } else {
                                toastr_error(data.message);
                            }
                        },
                        error: function() {

                        },
                    });

                });

            });
        });
    })
</script>